script_enemy_main{

let color=rand_int(1,6);

let shot1=0;
let bullet1=[];
let timer1=[];
let angle1=[];

let character="Tomomi";
let cutin=character;
let dispelled=0;
let spellcards=2;
if(GetCommonData("Difficulty")>=2){ spellcards=3; }
let damagerate=10;
let outfit=1;
outfit=(128*outfit)-128;
let usespell=0;
let bgfade=0;
let frame=0;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEspawn5=("script\SoundEffects\spawn5.wav");

let GRboss=("\script\Images\CharacterSprites\Tomomi.png");

#include_function "script/Functions/HealthBarLoad.txt";

@Initialize{
	LoadUserShotData("script\shots\ShotsTomomi1.txt");

	LoadSE("script\SoundEffects\spawn5.wav");

	LoadGraphic("\script\Images\CharacterSprites\Tomomi.png");

	SetLife(200);
	SetTimer(30);
	SetInvincibility(120);
	SetDamageRate(10,10);
	SetEnemyMarker(true);
	MagicCircle(true);
	SetColor(0,200,255);
	Concentration01(90);
	SetColor(255,255,255);
	SetShotColor(255,255,255);
	SetEffectForZeroLife(60,100,1);

	SetX(GetCommonData("Boss1X"));
	SetY(GetCommonData("Boss1Y"));
	SetMovePosition02(cx,miny+100,50);
	
	SetCommonData("Boss2Move",4);
}
	
@MainLoop{

SetCollisionA(GetX,GetY,16);
SetCollisionB(GetX,GetY,16);
SetShotAutoDeleteClip(16,16,16,16);

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=4; }
SetDamageRate(damagerate*weaken,damagerate*weaken);

HealthBar();

if(time%200==0 && time>=60){
	if(GetPlayerX>minx+50 && GetPlayerX<maxx-50){
	SetMovePosition01(GetPlayerX+rand(-30,30),rand(miny+60,miny+120),1.5);
	}
	if(GetPlayerX<=minx+50){
	SetMovePosition01(GetPlayerX+rand(15,30),rand(miny+60,miny+120),1.5);
	}
	if(GetPlayerX>=maxx-50){
	SetMovePosition01(GetPlayerX-rand(15,30),rand(miny+60,miny+120),1.5);
	}
}



if(GetCommonData("Difficulty")==1){

if((time+150)%240==0 && time>=90){
let angle=GetAngleToPlayer+360/18;
let angle2=rand(0,360);
color+=rand_int(1,3);
if(color>6){ color-=6; }
	loop(9){
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Tomomi - Nonspell 4 - Familiar.txt",GetX,GetY,3,angle,color);
	angle+=360/9;
	}
PlaySE(SEspawn5);
}

} //Easy


if(GetCommonData("Difficulty")==2){

if((time+150)%240==0 && time>=90){
let angle=GetAngleToPlayer+360/22;
let angle2=rand(0,360);
color+=rand_int(1,3);
if(color>6){ color-=6; }
	loop(11){
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Tomomi - Nonspell 4 - Familiar.txt",GetX,GetY,3,angle,color);
	angle+=360/11;
	}
PlaySE(SEspawn5);
}

} //Normal



if(GetCommonData("Difficulty")==3){

if((time+150)%240==0 && time>=90){
let angle=GetAngleToPlayer+360/26;
let angle2=rand(0,360);
color+=rand_int(1,3);
if(color>6){ color-=6; }
	loop(13){
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Tomomi - Nonspell 4 - Familiar.txt",GetX,GetY,3,angle,color);
	angle+=360/13;
	}
PlaySE(SEspawn5);
}

} //Hard


if(GetCommonData("Difficulty")==4){

if((time+150)%240==0 && time>=90){
let angle=GetAngleToPlayer+360/30;
let angle2=rand(0,360);
color+=rand_int(1,3);
if(color>6){ color-=6; }
	loop(15){
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Tomomi - Nonspell 4 - Familiar.txt",GetX,GetY,3,angle,color);
	angle+=360/15;
	}
PlaySE(SEspawn5);
}

} //Lunatic


time++; frame++;
if(usespell>0){ usespell--; } if(usespell<0){ usespell++; }
SetCommonData("Boss1X",GetX); SetCommonData("Boss1Y",GetY);

#include_function "script/Functions/HealthBar.txt";
}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRboss);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetRenderState(ALPHA);

	if(usespell>=1){
	SetGraphicRect(384,outfit,512,outfit+128);
	}
	if(usespell<=-1){
	SetGraphicRect(512,outfit,640,outfit+128);
	}

	if(usespell==0){
		if(GetSpeedX<=0.5 && GetSpeedX>=-0.5){ SetGraphicRect(0,outfit,128,outfit+128); }
		else if(GetSpeedX<-0.5){ SetGraphicRect(128,outfit,256,outfit+128); }
		else if(GetSpeedX>0.5){ SetGraphicRect(256,outfit,384,outfit+128); }
	}
	DrawGraphic(GetX,GetY);
}

@Finalize{
//	SetCommonData("Conversation",1);
}

}